<template>
	<view class="a-page">
		<a-nav-bar>
			<q-btn color="primary" label="新增订单" @click="store.增" />
			<q-btn color="negative" label="清缓存" @click="store.清缓存" v-if="a.是调试" />
			<q-toggle v-model="req.仅进行中" :label="显仅进行中" />
		</a-nav-bar>
		<a单项 v-for="(单项,index) in 单项组" :key="单项.id" :单项="单项" :store="store" />

		<view class="row flex-center q-pa-lg" v-if="单项组.length==0">
			没有数据……
		</view>
	</view>
</template>

<script setup>
	import { computed, ref, watch } from "vue"
	import * as util from '@/amtf/utils'
	import a单项 from './index单项.vue'

	import usestore from "./store.js"

	const store = usestore()
	const { 单项组, 单项集, setInputRef, 取编辑, req ,a} = store

	// const 仅进行中 = ref(true)
	const 显仅进行中 = computed(() => {
		let res = req.仅进行中 ? '进行中' : '全部'
		return res
	})

	const value = ref('0')
	import useshezhistore from "@/stores/shezhi-store"
	const shezhi = useshezhistore()
	const { a: 设置 } = shezhi

	function 现在(item) {
		// console.log('现在 item: ',item);
		item.结账时间 = Date.now()
	}

	function 其他商品小计(item) {
		let res = item.明细.reduce((sum, item) => {
			return sum + (item.小计 || 0)
		}, 0)
		res = util.数值圆整(res, 2)
		item.其他商品小计 = res
		return res
	}
</script>

<style>

</style>